package com.freewater.javabase.demo.guava.params;

import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;

import java.util.List;

public class Main {
    public static void main(String[] args) {
        // 非空判断
        String param1 = "hello";
        Preconditions.checkNotNull(param1, "params1 is null");
        String param2 = null;
        Preconditions.checkNotNull(param2, "params2 is null");
        // 预期值判断
        String param3 = "world";
        String param4 = "World";
        Preconditions.checkArgument(param3.equals(param4), "%s is not equal to %s", param3, param4);
        // 判断是否越界
        List<String> list = Lists.newArrayList("a", "b", "c", "d");
        Preconditions.checkElementIndex(5, list.size());
    }
}
